package com.axjy.web;

import com.axjy.dto.InspectiontaskDetailDto;
import com.axjy.dto.InspectiontaskMainDto;
import com.axjy.pojo.*;
import com.axjy.service.InspectiontaskDetailService;
import com.axjy.service.vo.Pager;
import com.axjy.util.Log;
import org.apache.ibatis.annotations.Param;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * Created by 00 on 2018/2/3.
 */
@RestController
@RequestMapping("/xj/qxdj")
public class InspectiontaskDetailHandler {

    @Resource
    private InspectiontaskDetailService service;

    @GetMapping("/search1")
    public List<Systemconfig> search1(){return service.search1();}

    @GetMapping("/search2")
    public List<Systemconfig> search2(){return service.search2();}

    @GetMapping("/djqrshow")
    public Pager djqrshow(@RequestParam(required = false,defaultValue = "0") Integer offset, @RequestParam(required = false,defaultValue = "4") Integer limit, @Param("dto") InspectiontaskDetailDto dto){
        Pager param=service.djqrshow(offset, limit, dto);
        return param;
    }

    @GetMapping("/zxshou")
    public Pager zxshou(@RequestParam(required = false,defaultValue = "0") Integer offset, @RequestParam(required = false,defaultValue = "4") Integer limit, @Param("dto") InspectiontaskMainDto dto){
        Pager pager=service.zxshow(offset, limit, dto);
        return pager;
    }

    @GetMapping("/qxshow")
    public Pager qxshow(@RequestParam(required = false,defaultValue = "0") Integer offset, @RequestParam(required = false,defaultValue = "4") Integer limit, @Param("dto") InspectiontaskMainDto dto){
        Pager pager=service.qxshow(offset, limit, dto);
        return pager;
    }

    @GetMapping("/search")
    public List<LineInfo> search(String lineCode){
        return service.search(lineCode);
    }

    @PostMapping("/hzupdate")
    public String hzupdate(InspectiontaskDetail inspectiontaskDetail){
        String isOk=null;
        try{
            service.hzupdate(inspectiontaskDetail);
            isOk="修改成功";
        }catch (Exception ex){
            isOk="修改失败";
            System.out.println();
            Log.logger.error(isOk,ex);
        }
        return isOk;
    }

    @PostMapping("/zxupdate")
    public String zxupdate(Integer id){
        String isOk=null;
        try{
            service.zxupdate(id);
            isOk="修改成功";
        }catch (Exception ex){
            isOk="修改失败";
            Log.logger.error(isOk,ex);
        }
        return isOk;
    }

    @RequestMapping("/hzwcupdate")
    public String hzwcupdate(Integer taskId){
        System.out.println("================"+taskId);
        String isOk=null;
        try{
            service.hzwcupdate(taskId);
            isOk="修改成功";
        }catch (Exception ex){
            isOk="修改失败";
            Log.logger.error(isOk,ex);
        }
        return isOk;
    }

}
